﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TeamFoundation;

namespace UCL.Powersource.TFS
{
    internal class TeamFoundationServerExtAdapter : ITeamFoundationServerExt
    {
        private TeamFoundationServerExt TeamFoundationServer;
        private ProjectContextExtAdapter _ActiveProjectContext;
        
        internal TeamFoundationServerExtAdapter(TeamFoundationServerExt TeamFoundationServer)
        {
            this.TeamFoundationServer = TeamFoundationServer;
            _ActiveProjectContext = new ProjectContextExtAdapter(TeamFoundationServer.ActiveProjectContext);
            TeamFoundationServer.ProjectContextChanged += TeamFoundationServer_ProjectContextChanged;
        }

        void TeamFoundationServer_ProjectContextChanged(object sender, EventArgs e)
        {
            _ActiveProjectContext = new ProjectContextExtAdapter(TeamFoundationServer.ActiveProjectContext);
            if (ProjectContextChanged != null) ProjectContextChanged(this, e);
        }
        
        public IProjectContextExt ActiveProjectContext
        {
            get 
            {
                return _ActiveProjectContext; 
            }
        }

        public event EventHandler ProjectContextChanged;
    }
}
